<template>
  <div class="el-div">
    <div class="el-div el-s">
      <el-input v-model="input" placeholder="请输入内容" size="mini"></el-input>
    </div>
    <div class="el-div">
      <el-button type="primary" icon="el-icon-search" size="mini"
      >搜索
      </el-button
      >
    </div>
    <div class="el-div">
      <el-button @click="cz" size="mini">重置</el-button>
    </div>
    <div class="el-div">
      <el-button
        type="primary"
        @click="
          tjxm()
        "
        size="mini"
      >添加环境参数
      </el-button
      >
      <el-dialog :title="title" :visible.sync="dialogFormVisible" width="30%">
        <el-form>
          <el-form-item label="参数名称：" :label-width="formLabelWidth">
            <el-input
              v-model="envParamsName"
              autocomplete="off"
              placeholder="请输入参数名称"
              size="mini"
            ></el-input>
          </el-form-item>
          <el-form-item label="环境参数：" :label-width="formLabelWidth">
            <el-table :data="envDetails.data.value" :show-header="false">
              <el-table-column prop="envId">
                <template slot-scope="scope">
                  <el-select v-model="scope.row.envId" size="mini">
                    <el-option
                      v-for="item in envList.data"
                      :key="item.id"
                      :label="item.name"
                      :value="item.id">
                    </el-option>
                  </el-select>
                  <!--                  <el-input-->
                  <!--                    size="mini"-->
                  <!--                    v-model="scope.row.envId"-->
                  <!--                    @input="-->
                  <!--                      inputChangedF(scope.$index, envDetails.data.value)-->
                  <!--                    "-->
                  <!--                    placeholder="key"-->
                  <!--                  ></el-input>-->
                </template>
              </el-table-column>
              <el-table-column prop="envValue">
                <template slot-scope="scope">
                  <el-input
                    size="mini"
                    v-model="scope.row.envValue"
                    @input="
                      inputChangedF(scope.$index, envDetails.data.value);
                    "
                    placeholder="key"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column width="35">
                <template slot-scope="scope">
                  <i class="el-icon-circle-plus-outline" @click="handleAdd(scope.$index, scope.row)"></i>
                </template>
              </el-table-column>
              <el-table-column width="35">
                <template slot-scope="scope">
                  <i
                    class="el-icon-remove-outline"
                    @click="
                      envParamsHandleDelete(scope.$index, envDetails.data.value)
                    "
                  ></i>
                </template>
              </el-table-column>
            </el-table>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false" size="mini"
          >取 消
          </el-button
          >
          <el-button
            type="primary"
            @click="dj()"
            size="mini"
          >确 定
          </el-button
          >
        </div>
      </el-dialog>
    </div>
    <el-table :data="envParamList.data.list" border size="mini">
      <el-table-column
        type="index"
        label="序号"
        width="80"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="name"
        label="环境名称"
        width="300"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="type"
        label="变量类型"
        align="center"
        :formatter="getType"
      ></el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        width="300"
        align="center"
        :formatter="createTimeFormatter"
      ></el-table-column>
      <el-table-column
        prop="updateTime"
        label="更新时间"
        width="300"
        align="center"
        :formatter="updateTimeFormatter"
      ></el-table-column>
      <el-table-column label="操作" align="center" width="200">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
          >编辑
          </el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
          >删除
          </el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      layout="total,sizes,prev,pager,next,jumper"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="envParamList.data.pageSize"
      :current-page="envParamList.data.pageNumber"
      :total="envParamList.data.total"
      style="float: right; margin-top: 10px; margin-bottom: 10px"
      :small="true"
    >
    </el-pagination>
  </div>
</template>

<script>
  import index from './index';

  export default index;

</script>
<style>

  @import "index.css";

</style>
